#!/usr/bin/env python

"Functions that check if string is convertible to another type."


def isint(s):
    'Return True if string can be converted to an integer.'
    try:
        int(s)
        rv = True
    except ValueError:
        rv = False
    return rv


def isfloat(s):
    'Return True if string can be converted to a floating point value'
    try:
        float(s)
        rv = True
    except ValueError:
        rv = False
    return rv


def isStringTrue(s):
    '''Translate string to its logical value.

    Return True or False.
    Raise ValueError if the string is not understood.
    '''
    if s == "yes":
        return True
    elif s == "no":
        return False
    else:
        emsg = 'String must be either "yes" or "no".'
        raise ValueError(emsg)
